// router/index.ts
import { createRouter, createWebHashHistory, createWebHistory } from 'vue-router'
import HomeView from '../views/Home.vue'
import EditorView from '../views/Editor.vue'

const routes = [
  {
    path: "/",
    redirect: "/home",
  },
  {
    path: "/home",
    name: "home",
    component: HomeView,
  },
  {
    path: "/editor/:id",
    name: "editor",
    component: EditorView,
  },
  {
    path: '/layout',
    name: 'layout',
    component: () => import('../views/layout/Index.vue'),
    children: [
      {
        path: 'docs',
        name: 'docs',
        component: () => import('../views/docs/Index.vue'),
      },
      {
        path: 'template',
        name: 'template',
        component: () => import('../views/template/Index.vue'),
      },
      {
        path: 'prompt',
        name: 'prompt',
        component: () => import('../views/prompt/Index.vue'),
      },
      {
        path: 'knowledge',
        name: 'knowledge',
        component: () => import('../views/knowledge/Index.vue'),
      },
    ]
  },
  {
    path: '/templateEdit/:id',
    name: 'templateEdit',
    component: () => import('../views/template/Edit.vue'),
  },
];

const router = createRouter({
  history: import.meta.env.VITE_ROUTER_HISTORY === 'hash' ? createWebHashHistory() : createWebHistory(),
  routes: routes,
});

export default router;
